package com.ruoyi.web.controller.example;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.student.domain.Student;
import com.ruoyi.student.service.StudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Anonymous

@RestController
@Api(tags = "学生管理")
public class NewStudentController {

    @Autowired
    StudentService service;
    //获取学生列表
    @GetMapping ("/GetStudentList")
    @ApiOperation(value = "学生列表")
    public AjaxResult GetStudentList(){
        return AjaxResult.success(service.getStudentList());
    }

    //新增学生
    @PostMapping("/InsertStudent")
    @ApiOperation(value = "新增学生")
    public AjaxResult InsertStudent(@RequestBody Student student) {
        return AjaxResult.success(service.insertStudent(student));
    }
    //修改
    @PostMapping("/UpdateStudent")
    @ApiOperation(value = "修改学生")
    public AjaxResult UpdateStudent(@RequestBody Student student) {
        return AjaxResult.success(service.updateStudent(student));
    }
    //删除
    @GetMapping("/DeleteStudent")
    @ApiOperation(value = "删除学生")
    public AjaxResult DeleteStudent(@RequestBody int id) {
        return AjaxResult.success(service.deleteStudent(id));
    }
}
